"""
监控指标相关模型
"""
from pydantic import BaseModel
from typing import Optional, Dict, Any, List
from datetime import datetime

class MetricBase(BaseModel):
    """监控指标基础模型"""
    machine_id: int
    cpu_percent: Optional[float] = None
    cpu_count: Optional[int] = None
    cpu_count_logical: Optional[int] = None
    cpu_freq_current: Optional[float] = None
    memory_total: Optional[int] = None
    memory_available: Optional[int] = None
    memory_percent: Optional[float] = None
    memory_used: Optional[int] = None
    swap_total: Optional[int] = None
    swap_used: Optional[int] = None
    swap_percent: Optional[float] = None
    disk_info: Optional[str] = None
    network_bytes_sent: Optional[int] = None
    network_bytes_recv: Optional[int] = None
    network_packets_sent: Optional[int] = None
    network_packets_recv: Optional[int] = None

class MetricCreate(MetricBase):
    """创建监控指标模型"""
    pass

class Metric(MetricBase):
    """监控指标模型"""
    id: int
    timestamp: datetime
    created_at: datetime

    class Config:
        orm_mode = True

class AgentConfig(BaseModel):
    """Agent配置模型"""
    machine_id: int
    interval: Optional[int] = 30
    collect_system_info: Optional[bool] = True
    collect_cpu_info: Optional[bool] = True
    collect_memory_info: Optional[bool] = True
    collect_disk_info: Optional[bool] = True
    collect_network_info: Optional[bool] = True
    collect_process_info: Optional[bool] = False
    collect_log_info: Optional[bool] = False
    collect_database_info: Optional[bool] = False
    log_paths: Optional[List[str]] = []
    database_configs: Optional[List[Dict[str, Any]]] = []
    port_list: Optional[List[int]] = []
    process_names: Optional[List[str]] = []  # 添加进程名称列表属性
    
    class Config:
        orm_mode = True
